﻿using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Debug;
using Net5ApiAndEfMySql.PoModel.SystemAdmin;
using System;
using System.Collections.Generic;
using System.Text;

namespace Net5ApiAndEfMySql.Repository
{
    public class SoaSystemCenterDbContext : DbContext
    {
        //还有一种查看sql的方式是  调试->窗口->即时 执行代码 IQueryable.ToQueryString();
        #region 利用日志输出ef执行Sql, 查看方式:点击VisualStudio工具条：调试->窗口->输出，打开输出日志，并搜索EntityFrameworkCore

        [Obsolete]
        public static readonly LoggerFactory LoggerFactory = new LoggerFactory(new[] { new DebugLoggerProvider() });
      

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);
            optionsBuilder.UseLoggerFactory(LoggerFactory);
        }
        #endregion
        public SoaSystemCenterDbContext(DbContextOptions<SoaSystemCenterDbContext> options) : base(options)
        {
        }
        public virtual DbSet<AdminUserPo> AdminUserPo { get; set; }

        public virtual DbSet<RoleDbPo> RoleDbPo { get; set; }

        public virtual DbSet<RoleModuleRelationPo> RoleModuleRelationPo { get; set; }

        public virtual DbSet<AdminUserRoleRelationPo> AdminUserRoleRelationPo { get; set; }

        public virtual DbSet<MenuDbPo> MenuDbPo { get; set; }

    }
}
